package com.itheima.web.servlet;

import com.itheima.entity.Patient;
import com.itheima.service.PatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.List;

@Controller
public class PatientServlet {
    @Autowired
    PatientService patientService;
    @RequestMapping(value = "/patient",method = RequestMethod.GET)
    public String getPatient(Model mv){
        List<Patient> list = patientService.findAllPatient();
        mv.addAttribute("list",list);
        return "user/user-list";
    }
    @RequestMapping(value="/patient",method = RequestMethod.POST)
    public String addPatient(Patient patient){
        patientService.addPatient(patient);
        return "redirect:/patient";
    }

}
